import { http } from "@/utils/http";

// 访客实体类型
export interface Visitor {
  id: number;
  name: string;
  sex: number;
  cardId: string;
  image: string;
  phone: string;
  cellId: number;
  cellBuilding: number;
  cellUnit: number;
  cellHouse: string;
  tenantId: number;
  createTime: string;
  updateTime: string;
  isDeleted: number;
}

// 访客列表请求参数
export interface VisitorListParams {
  page?: number;
  size?: number;
  keyword?: string;
  sex?: number;
  [key: string]: any;
}

// 访客列表响应（更新为匹配后端实际返回的结构）
export interface VisitorListResponse {
  code: number;
  data: Visitor[]; // data直接是访客数组
  message: string;
}

// 访客统计数据
export interface VisitorStats {
  total: number; // 所有访客
  current: number; // 当前访客
  pending: number; // 待访来客
}

// 分页查询访客列表
export const getVisitorList = (params?: VisitorListParams) => {
  return http.request<VisitorListResponse>("post", "/visitor/list", {
    data: params
  });
};

// 添加访客
export const addVisitor = (data?: any) => {
  return http.request<ApiResponse>("post", "/visitor/add", { data });
};

// 删除访客
export const deleteVisitor = (id: number) => {
  return http.request<ApiResponse>("get", `/visitor/delete?id=${id}`);
};
// 通用响应接口
export interface ApiResponse<T = any> {
  code: number;
  data?: T;
  message: string;
}
